package View;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;



public class ClientMainConnectionWindow extends JFrame implements ActionListener{
	
	JTextField text = new JTextField();
	
	public ClientMainConnectionWindow ()
	{
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
		setTitle("Connexion");
		setSize(400, 100);
		
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		

		JLabel label1 = new JLabel(" ");
		contentPane.add(label1, BorderLayout.NORTH);
		
		JLabel label2 = new JLabel(" ");
		contentPane.add(label2, BorderLayout.SOUTH);
		
		JLabel label = new JLabel("Enter a pseudo :");
		contentPane.add(label, BorderLayout.WEST);
		
		contentPane.add(text, BorderLayout.CENTER);
		
		JButton connect = new JButton("Connect");
		contentPane.add(connect, BorderLayout.EAST);
		
		setContentPane(contentPane);
		
		setVisible(true);
		
		connect.addActionListener(this);
			
	}
	
	
	public static void main(String argv[])
	{
		ClientMainConnectionWindow clientMain = new ClientMainConnectionWindow();
	}
	

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
		String userName = this.text.getText();
		
		if (!userName.isEmpty()){
			
			new ClientMainFrame(userName);
			
			dispose();
		}
		 
		
	}

}
